package application;

import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polyline;

import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.stage.Stage;

public class ShowPolyline extends Application{

	@Override
	public void start(Stage primaryStage) {
		
		Scene scene = new Scene(new MyPolyline(), 400, 400);
		primaryStage.setTitle("ShowPolygon");
		primaryStage.setScene(scene);
		primaryStage.show();
		
	}
	
	public static void main(String[] args) {
		Application.launch(args);
	}
}


class MyPolyline extends Pane{
	private void paint() {
		Polyline polyline = new Polyline();
		polyline.setFill(Color.WHITE);
		polyline.setStroke(Color.BLACK);
		ObservableList<Double>  list = polyline.getPoints();
		
		double centerX = getWidth() / 2, centerY = getHeight() / 2;
		double radius = Math.min(getWidth(), getHeight()) * 0.4;
		
		for (int i = 0; i < 6; i++) {
			list.add(centerX + radius * Math.cos(2 * i *Math.PI / 6));
			list.add(centerY - radius * Math.sin(2 * i *Math.PI / 6));

		}
		

		getChildren().clear();
		getChildren().add(polyline);
	}
	
	@Override
	public void setWidth(double width) {
		super.setWidth(width);
		paint();
	}
	
	@Override
	public void setHeight(double height) {
		super.setHeight(height);
		paint();
	}
	
	
	
	
	
}